package 我的Java学习_算法基础.day_08;

import java.util.Scanner;

/**
 * @author 挚爱之夕
 * @date 2021/8/23 - 08 - 23 - 19:59
 * @Description: 我的Java学习.day_08
 * @Version: 1.0
 */
public class _127_字典序最小问题 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        StringBuilder sb = new StringBuilder();
        int n = sc.nextInt();
        for (int i = 0; i < n; i++) {
            sb.append(sc.next());
        }
        f(sb.toString());
    }

    private static void f(String s) {
        String s1 = new StringBuilder(s).reverse().toString();
        StringBuilder sb = new StringBuilder();
        int length = s1.length();
        int row = 0;
        while (true) {
            if (s.compareTo(s1) <= 0) {
                sb.append(s.charAt(0));
                s = s.substring(1);
            } else if (s.compareTo(s1) > 0) {
                sb.append((s1.charAt(0)));
                s1 = s1.substring(1);
            }
            if (sb.length() % 80 == 0) {
                System.out.println(sb.substring(row * 80, (row + 1) * 80));
                row++;
            }
            if (sb.length() == length) {
                break;
            }

        }
        if (sb.length() > row * 80) {
            System.out.println(sb.substring(row * 80));
        }
    }
}
